import {
  recommend_issue,
  recommend_policy,
  recommend_norm,
  getInfo,
  getAboutList,
} from '@/assets/api/quizData.js'
import {
  getCollegeList
} from "@/assets/api/schoolApi";


export const state = () => ({

  entering: false, // 对方是否正在输入

  mdcsList: null,
  recommendList: null,
  normList: null,
  policyList: null,

  info: null,
  aboutList: [],
  relateddata: [],


})

export const getters = {
  hotSearchList: (state) => state.hotSearchList,

  mdcsList: (state) => state.mdcsList,
  recommendList: (state) => state.recommendList,
  normList: (state) => state.normList,
  policyList: (state) => state.policyList,

  info: (state) => state.info,
  aboutList: (state) => state.aboutList,
  relateddata: (state) => state.relateddata,
}

export const mutations = {

  set_entering(state, data) {
    state.entering = data
  },
  set_Init(state, data) {
    state.mdcsList = data.mdcsList
    state.recommendList = data.recommendList
    state.normList = data.normList
    state.policyList = data.policyList
  },

  set_DetailInit(state, data) {
    state.info = data.info
    state.aboutList = data.aboutList
    state.relateddata = data.relateddata
  }
}

export const actions = {
  // 获取用户信息
  async quizInit({
    commit,
    state
  }, params) {
    const res1 = await getCollegeList({
      limit: 10,
      md_type: "0",
      page: 1,
      type: 2,
    })
    const res2 = await recommend_issue({})
    const res3 = await recommend_norm({})
    const res4 = await recommend_policy({})
    // commit('set_Init', {
    //     mdcsList: res1.data.data,
    //     recommendList: res2.data,
    //     normList: res3.data,
    //     policyList: res4.data,
    // })
    commit('set_Init', {
      mdcsList: res1,
      recommendList: res2,
      normList: res3,
      policyList: res4,
    })
  },

  async DetailInit({
    commit,
    state
  }, params) {
    // const res1 = await getInfo({
    //     id: params.id,
    // })
    const res2 = await getAboutList({
      page: 1,
      limit: 10,
      id: params.id
    })
    const res3 = await recommend_issue({})
    commit('set_DetailInit', {
      info: null,
      aboutList: res2.data,
      relateddata: res3.data,
    })
  },

}
